home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / util / vtt1_3a.zip / TTVIEW.CPP < prev    next >
C/C++ Source or Header  |  1994-09-11  |  22KB  |  672 lines

  1. // ttview.h : interface of the CTtView class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. //class MacComm;
  5.  
  6. class XYModem;
  7.  
  8. class CTtView : public CView
  9. {
  10. protected: // create from serialization only
  11.         CTtView();
  12.         DECLARE_DYNCREATE(CTtView)
  13.  
  14. // Attributes
  15. public:
  16.         CTtDoc*         GetDocument();
  17.     CDC                 cdcTTY;
  18.     CString     strTemp;
  19.     MacComm*    commObj;
  20.     MacTerm*    termObj;
  21.     XYModem*    xferObj;
  22.     
  23.     CString     DLPath;
  24.     CString     ULPath;
  25.     BOOL                initFlag;
  26.     int                 DefaultTextColor;
  27.     int                 DefaultBackgroundColor;
  28.      
  29. // Operations
  30. public:
  31.  
  32. void UpdateStatusBar(int Pane, LPSTR NewText);
  33.  
  34. // Implementation
  35. public:
  36.         virtual ~CTtView();
  37.         virtual void OnDraw(CDC* pDC);  // overridden to draw this view
  38. #ifdef _DEBUG
  39.         virtual void AssertValid() const;
  40.         virtual void Dump(CDumpContext& dc) const;
  41. #endif
  42.  
  43. protected:
  44.  
  45. // Generated message map functions
  46. protected:
  47.         //{{AFX_MSG(CTtView)
  48.         afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  49.         afx_msg void OnHelpStat();
  50.         afx_msg void OnUtilsHangup();
  51.         afx_msg void OnSize(UINT nType, int cx, int cy);
  52.         afx_msg void OnFileNew();
  53.         afx_msg void OnUtilsFastscroll();
  54.         afx_msg void OnUpdateUtilsFastscroll(CCmdUI* pCmdUI);
  55.         afx_msg void OnSetFocus(CWnd* pOldWnd);
  56.         afx_msg void OnKillFocus(CWnd* pNewWnd);
  57.         afx_msg void OnFileClosecapturefile();
  58.         afx_msg void OnUpdateFileClosecapturefile(CCmdUI* pCmdUI);
  59.         afx_msg void OnFileOpencapturefile();
  60.         afx_msg void OnUpdateFileOpencapturefile(CCmdUI* pCmdUI);
  61.         afx_msg void OnViewSettextcolor();
  62.         afx_msg void OnViewSetbackgroundcolor();
  63.         afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  64.         afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  65.         afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  66.         afx_msg void OnDLXmodem();
  67.         afx_msg void OnDLYmodem();
  68.         afx_msg void OnUtilsCheckCarrier();
  69.         afx_msg void OnAbortdl();
  70.         afx_msg void OnUpdateAbortdl(CCmdUI* pCmdUI);
  71.         afx_msg void OnUpdateDLXmodem(CCmdUI* pCmdUI);
  72.         afx_msg void OnUpdateDLYmodem(CCmdUI* pCmdUI);
  73.         afx_msg void OnDLYmodemg();
  74.         afx_msg void OnUpdateDLYmodemg(CCmdUI* pCmdUI);
  75.         afx_msg void OnULXmodem();
  76.         afx_msg void OnUpdateULXmodem(CCmdUI* pCmdUI);
  77.         afx_msg void OnULYmodem();
  78.         afx_msg void OnUpdateULYmodem(CCmdUI* pCmdUI);
  79.         afx_msg void OnULYmodemg();
  80.         afx_msg void OnUpdateULYmodemg(CCmdUI* pCmdUI);
  81.         afx_msg void OnULXmodem128bytecrc();
  82.         afx_msg void OnUpdateULXmodem128bytecrc(CCmdUI* pCmdUI);
  83.         afx_msg void OnULXmodem1k();
  84.         afx_msg void OnUpdateULXmodem1k(CCmdUI* pCmdUI);
  85.         afx_msg void OnUtilsSetupUldir();
  86.         afx_msg void OnUtilsSetupDldir();
  87.         afx_msg void OnUpdateUtilsHangup(CCmdUI* pCmdUI);
  88.         afx_msg void OnUpdateUtilsSetupDldir(CCmdUI* pCmdUI);
  89.         afx_msg void OnUpdateUtilsSetupUldir(CCmdUI* pCmdUI);
  90.         afx_msg void OnUpdateViewSetbackgroundcolor(CCmdUI* pCmdUI);
  91.         afx_msg void OnUpdateViewSettextcolor(CCmdUI* pCmdUI);
  92.         afx_msg void OnUpdateUtilsResetport(CCmdUI* pCmdUI);
  93.         afx_msg void OnUtilsResetport();
  94.         //}}AFX_MSG
  95.         DECLARE_MESSAGE_MAP()
  96. };
  97.  
  98. #ifndef _DEBUG  // debug version in ttview.cpp
  99. inline CTtDoc* CTtView::GetDocument()
  100.    { return (CTtDoc*)m_pDocument; }
  101. #endif
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. /////////////////////////////////////////////////////////////////////////////
  105. /////////////////////////////////////////////////////////////////////////////
  106. /////////////////////////////////////////////////////////////////////////////
  107. /////////////////////////////////////////////////////////////////////////////
  108.  
  109. // ttview.cpp : implementation of the CTtView class
  110. //
  111.  
  112. #include "windows.h"
  113. #include <commdlg.h>
  114. #include "stdafx.h"
  115. #include "tt.h"
  116. #include "maccomm.h" 
  117. #include "macterm.h"
  118. #include "xymodem.h"
  119. //#include "setup.h"
  120.  
  121. #include "statdlg.h"
  122. #include "ttdoc.h"
  123. #include "ttview.h"
  124.  
  125. #ifdef _DEBUG
  126. #undef THIS_FILE
  127. static char BASED_CODE THIS_FILE[] = __FILE__;
  128. #endif
  129.  
  130.  
  131. /////////////////////////////////////////////////////////////////////////////
  132. // CTtView
  133.  
  134. IMPLEMENT_DYNCREATE(CTtView, CView)
  135.  
  136. BEGIN_MESSAGE_MAP(CTtView, CView)
  137.         //{{AFX_MSG_MAP(CTtView)
  138.         ON_WM_SHOWWINDOW()
  139.         ON_COMMAND(ID_HELP_STAT, OnHelpStat)
  140.         ON_COMMAND(ID_UTILS_HANGUP, OnUtilsHangup)
  141.         ON_WM_SIZE()
  142.         ON_COMMAND(ID_FILE_NEW, OnFileNew)
  143.         ON_COMMAND(ID_UTILS_FASTSCROLL, OnUtilsFastscroll)
  144.         ON_UPDATE_COMMAND_UI(ID_UTILS_FASTSCROLL, OnUpdateUtilsFastscroll)
  145.         ON_WM_SETFOCUS()
  146.         ON_WM_KILLFOCUS()
  147.         ON_COMMAND(ID_FILE_CLOSECAPTUREFILE, OnFileClosecapturefile)
  148.         ON_UPDATE_COMMAND_UI(ID_FILE_CLOSECAPTUREFILE, OnUpdateFileClosecapturefile)
  149.         ON_COMMAND(ID_FILE_OPENCAPTUREFILE, OnFileOpencapturefile)
  150.         ON_UPDATE_COMMAND_UI(ID_FILE_OPENCAPTUREFILE, OnUpdateFileOpencapturefile)
  151.         ON_COMMAND(ID_VIEW_SETTEXTCOLOR, OnViewSettextcolor)
  152.         ON_COMMAND(ID_VIEW_SETBACKGROUNDCOLOR, OnViewSetbackgroundcolor)
  153.         ON_WM_CHAR()
  154.         ON_WM_KEYDOWN()
  155.         ON_WM_KEYUP()
  156.         ON_COMMAND(ID_DL_XMODEM, OnDLXmodem)
  157.         ON_COMMAND(ID_DL_YMODEM, OnDLYmodem)
  158.         ON_COMMAND(ID_UTILS_CHECKCARRIER, OnUtilsCheckCarrier)
  159.         ON_COMMAND(ID_ABORTDL, OnAbortdl)
  160.         ON_UPDATE_COMMAND_UI(ID_ABORTDL, OnUpdateAbortdl)
  161.         ON_UPDATE_COMMAND_UI(ID_DL_XMODEM, OnUpdateDLXmodem)
  162.         ON_UPDATE_COMMAND_UI(ID_DL_YMODEM, OnUpdateDLYmodem)
  163.         ON_COMMAND(ID_DL_YMODEMG, OnDLYmodemg)
  164.         ON_UPDATE_COMMAND_UI(ID_DL_YMODEMG, OnUpdateDLYmodemg)
  165.         ON_COMMAND(ID_UL_XMODEM, OnULXmodem)
  166.         ON_UPDATE_COMMAND_UI(ID_UL_XMODEM, OnUpdateULXmodem)
  167.         ON_COMMAND(ID_UL_YMODEM, OnULYmodem)
  168.         ON_UPDATE_COMMAND_UI(ID_UL_YMODEM, OnUpdateULYmodem)
  169.         ON_COMMAND(ID_UL_YMODEMG, OnULYmodemg)
  170.         ON_UPDATE_COMMAND_UI(ID_UL_YMODEMG, OnUpdateULYmodemg)
  171.         ON_COMMAND(ID_UL_XMODEM128BYTECRC, OnULXmodem128bytecrc)
  172.         ON_UPDATE_COMMAND_UI(ID_UL_XMODEM128BYTECRC, OnUpdateULXmodem128bytecrc)
  173.         ON_COMMAND(ID_UL_XMODEM1K, OnULXmodem1k)
  174.         ON_UPDATE_COMMAND_UI(ID_UL_XMODEM1K, OnUpdateULXmodem1k)
  175.         ON_COMMAND(ID_UTILS_SETUP_ULDIR, OnUtilsSetupUldir)
  176.         ON_COMMAND(ID_UTILS_SETUP_DLDIR, OnUtilsSetupDldir)
  177.         ON_UPDATE_COMMAND_UI(ID_UTILS_HANGUP, OnUpdateUtilsHangup)
  178.         ON_UPDATE_COMMAND_UI(ID_UTILS_SETUP_DLDIR, OnUpdateUtilsSetupDldir)
  179.         ON_UPDATE_COMMAND_UI(ID_UTILS_SETUP_ULDIR, OnUpdateUtilsSetupUldir)
  180.         ON_UPDATE_COMMAND_UI(ID_VIEW_SETBACKGROUNDCOLOR, OnUpdateViewSetbackgroundcolor)
  181.         ON_UPDATE_COMMAND_UI(ID_VIEW_SETTEXTCOLOR, OnUpdateViewSettextcolor)
  182.         ON_UPDATE_COMMAND_UI(ID_UTILS_RESETPORT, OnUpdateUtilsResetport)
  183.         ON_COMMAND(ID_UTILS_RESETPORT, OnUtilsResetport)
  184.         //}}AFX_MSG_MAP
  185. END_MESSAGE_MAP()
  186.  
  187.  
  188. /////////////////////////////////////////////////////////////////////////////
  189. // CTtView construction/destruction
  190.  
  191. CTtView::CTtView()  {
  192.  
  193.      // create instances of objects
  194.         commObj = new MacComm;
  195.     termObj = new MacTerm;
  196.         xferObj = new XYModem;    
  197.  
  198.     initFlag = FALSE;
  199. }
  200.  
  201. CTtView::~CTtView()
  202. {    // clean up
  203.         delete commObj;
  204.         delete termObj;
  205.     delete xferObj;
  206. }
  207.  
  208. /////////////////////////////////////////////////////////////////////////////
  209. // CTtView drawing
  210.  
  211. void CTtView::OnDraw(CDC* pDC)  {
  212.  
  213.         CTtDoc* pDoc = GetDocument();
  214.         ASSERT_VALID(pDoc);
  215.  
  216.         // TODO: add draw code for native data here
  217. }
  218.  
  219. /////////////////////////////////////////////////////////////////////////////
  220. // CTtView diagnostics
  221.  
  222. #ifdef _DEBUG
  223. void CTtView::AssertValid() const  {
  224.  
  225.         CView::AssertValid();
  226. }
  227.  
  228. void CTtView::Dump(CDumpContext& dc) const  {
  229.  
  230.         CView::Dump(dc);
  231. }
  232.  
  233. CTtDoc* CTtView::GetDocument()  {   // non-debug version is inline
  234.  
  235.         ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTtDoc)));
  236.         return (CTtDoc*)m_pDocument;
  237. }
  238. #endif //_DEBUG
  239.  
  240. /////////////////////////////////////////////////////////////////////////////
  241. // CTtView message handlers
  242.  
  243.  
  244. //*****************************************************
  245. // screen stuff...
  246. //  Here we initialize the commObj, initialize the termObj and cross link
  247. //  the two objects. (each has a pointer to to the other. 
  248.  
  249. void CTtView::OnShowWindow(BOOL bShow, UINT nStatus)  {
  250.  
  251.         CView::OnShowWindow(bShow, nStatus);
  252.         
  253.  
  254.  
  255.     // here we call the PortSetup() member function of the commObj.
  256.     // we also could set the port parameters in the public data members
  257.     // of the commObj.
  258.     if(commObj->idCom1 == -1)   {         // -1 means not initialized
  259.                 if(commObj->PortSetup() )  {      // do the setup dialog
  260.                         if(commObj->OpenPort(this) )  // open the port, pass owner pointer (this)
  261.                                 AfxMessageBox("Error in CommMsgAssign");
  262.                         }
  263.                 }       
  264.  
  265.  
  266.         if(termObj->OpenScreen(this) )         // create screen, pass owner pointer(this)               
  267.                 AfxMessageBox("Error in TermOpen");
  268.  
  269.     commObj->Screen = termObj;   //  cross link comm obj and assoc screen
  270.     termObj->Comm   = commObj;                        
  271.  
  272.         // recover defaults
  273.     DLPath = AfxGetApp()->GetProfileString("Main", "DLDir","C:\\" );
  274.     ULPath = AfxGetApp()->GetProfileString("Main", "ULDir","C:\\" );
  275.     DefaultBackgroundColor = AfxGetApp()->GetProfileInt("Main", 
  276.                                                         "BackGroundColor", 1);
  277.     DefaultTextColor = AfxGetApp()->GetProfileInt("Main", "TextColor", 15);
  278.         
  279.         termObj->SetTextColor(DefaultTextColor);     // set colors
  280.         termObj->SetBkgndColor(DefaultBackgroundColor);
  281. }                                                     
  282.  
  283. //////////////////////////////
  284. //  This displays the char buffer stats from menu
  285.  
  286. void CTtView::OnHelpStat()  {
  287.  
  288.         StatDlg it;
  289.         it.SetData(commObj);
  290.         it.DoModal();
  291. }
  292.  
  293.  
  294. /////////////////////////////
  295. //  Calls HangUp function in commObj
  296. void CTtView::OnUtilsHangup()  {
  297.  
  298.         commObj->HangUp();      
  299. }
  300.  
  301.  
  302. /////////////////////////////
  303. //  This is a workaround for the WM_COMMNOTIFY notifications stopping for
  304. //  some reason upon sizing.  The VerifyInt() function does just that.
  305. void CTtView::OnSize(UINT nType, int cx, int cy)  {
  306.  
  307.         CView::OnSize(nType, cx, cy);
  308.         
  309.         commObj->VerifyInt();
  310. }
  311.  
  312. void CTtView::OnSetFocus(CWnd* pOldWnd)  {
  313.  
  314.         CView::OnSetFocus(pOldWnd);
  315.         
  316.         commObj->VerifyInt();
  317. }
  318.  
  319. // this was not used, just too lazy to take it out
  320. void CTtView::OnKillFocus(CWnd* pNewWnd)  {
  321.  
  322.         CView::OnKillFocus(pNewWnd);
  323.         
  324.         // TODO: Add your message handler code here
  325. }
  326.  
  327. //////////////////////////////////
  328. // cheap re-dial - sends A/ to comm port for repeat last.
  329. void CTtView::OnFileNew()  {
  330.  
  331.         commObj->CommSendString("a/");
  332. }
  333.  
  334. //////////////////////////////////
  335. //  Key handling
  336. //  These member functions map key strokes fro the application over the the commObj.
  337. //  There are other ways to do this, but this works the best, leaving key message
  338. //  processing in the view of the app.
  339.  
  340. void CTtView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)   {
  341.  
  342.         commObj->OnKeyDown(nChar, nRepCnt, nFlags);
  343.         
  344.         CView::OnKeyDown(nChar, nRepCnt, nFlags);
  345. }
  346.  
  347. void CTtView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)    {
  348.  
  349.         commObj->OnKeyUp(nChar, nRepCnt, nFlags);
  350.         
  351.         CView::OnKeyUp(nChar, nRepCnt, nFlags);
  352. }
  353.  
  354. void CTtView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)   {
  355.  
  356.         commObj->OnChar(nChar, nRepCnt, nFlags);
  357.     
  358.         CView::OnChar(nChar, nRepCnt, nFlags);
  359. }
  360.  
  361. /////////////////////////////////////////////
  362. //  The first function toggles on/off the fastscroll option in the termObj.
  363. //  The second function updates the menu check status for this selection
  364. void CTtView::OnUtilsFastscroll()   {
  365.  
  366.                 // toggle Fastscroll
  367.         if(termObj->fFastScroll) termObj->fFastScroll = FALSE;
  368.         else termObj->fFastScroll = TRUE;       
  369. }
  370. void CTtView::OnUpdateUtilsFastscroll(CCmdUI* pCmdUI)  {
  371.  
  372.  
  373.         if(termObj->fFastScroll) pCmdUI->SetCheck(1);
  374.         else pCmdUI->SetCheck(0);
  375. }
  376.  
  377. /////////////////////////////////////////////////////
  378. // these functions control the capture file and graying menu choices
  379.  
  380. void CTtView::OnFileClosecapturefile()  {
  381.  
  382.         commObj->CloseCaptureFile();
  383.     UpdateStatusBar(4,"Capture - OFF");
  384. }
  385.  
  386. void CTtView::OnUpdateFileClosecapturefile(CCmdUI* pCmdUI)  {
  387.  
  388.         if(!commObj->fp1) pCmdUI->Enable(FALSE);        
  389.     else pCmdUI->Enable(TRUE);
  390. }
  391.  
  392. void CTtView::OnFileOpencapturefile()  {
  393.  
  394.         if(commObj->OpenCaptureFile() ) 
  395.          UpdateStatusBar(4,"Capture - OFF");
  396.         else UpdateStatusBar(4,"Capture - ON ");
  397. }
  398.  
  399. void CTtView::OnUpdateFileOpencapturefile(CCmdUI* pCmdUI)  {
  400.  
  401.         if(commObj->fp1) pCmdUI->Enable(FALSE); 
  402.     else pCmdUI->Enable(TRUE);
  403.  
  404. }
  405.  
  406. //////////////////////////////////////////////////
  407. //  These functions set the screen colors.  
  408.  
  409. void CTtView::OnViewSettextcolor()  {
  410.  
  411. int Color = termObj->SetTextColor();
  412.  
  413.         if(Color == -1) return;
  414.         
  415.         if(Color != DefaultTextColor)   {
  416.             DefaultTextColor = Color;
  417.         AfxGetApp()->WriteProfileInt("Main", "TextColor", Color);
  418.                 }               
  419. }
  420.  
  421. void CTtView::OnViewSetbackgroundcolor()  {
  422.  
  423. int Color = termObj->SetBkgndColor();
  424.  
  425.         if(Color == -1) return;
  426.         
  427.         if(Color != DefaultBackgroundColor)     {
  428.             DefaultBackgroundColor = Color;
  429.         AfxGetApp()->WriteProfileInt("Main", "BackGroundColor", Color);
  430.                 }               
  431. }
  432.  
  433.      // disable during file xfers
  434. void CTtView::OnUpdateViewSetbackgroundcolor(CCmdUI* pCmdUI)  {
  435.  
  436.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  437.     else pCmdUI->Enable(TRUE);
  438. }
  439.      // disable during file xfers
  440. void CTtView::OnUpdateViewSettextcolor(CCmdUI* pCmdUI)   {
  441.  
  442.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  443.     else pCmdUI->Enable(TRUE);
  444. }
  445.  
  446.  
  447.  
  448. ////////////////////////////////////////////////////////
  449. //  function to update status bar
  450.  
  451. void CTtView::UpdateStatusBar(int Pane, LPSTR NewText)  {
  452.  
  453. CStatusBar *StatusBar = ( CStatusBar * )
  454.         AfxGetApp()->m_pMainWnd->GetDescendantWindow( AFX_IDW_STATUS_BAR );
  455.  
  456.         if( StatusBar != 0 )
  457.         {
  458.                 StatusBar->SetPaneText( Pane, NewText );
  459.         }
  460.  
  461. }
  462.  
  463.  
  464. ///////////////////////////////////////////////////////
  465. // Downloading functions
  466. void CTtView::OnDLXmodem()   {
  467.  
  468.         xferObj->ReceiveXY (commObj, DLPath.GetBuffer(DLPath.GetLength()), 'X');
  469.         DLPath.ReleaseBuffer();
  470. }                                                   
  471.  
  472. void CTtView::OnDLYmodem()   {
  473.  
  474.     xferObj-> ReceiveFile(commObj, DLPath.GetBuffer(DLPath.GetLength()), "", 'Y');
  475.         DLPath.ReleaseBuffer();
  476. }
  477.  
  478. void CTtView::OnDLYmodemg()  {
  479.  
  480.     xferObj->ReceiveFile(commObj, DLPath.GetBuffer(DLPath.GetLength()), "", 'G');
  481.         DLPath.ReleaseBuffer();
  482. }
  483.  
  484. ///////////////////////////////////////////////////////
  485. // Uploading functions
  486.  
  487.    // Std Xmodem - 128 byte - checksum
  488. void CTtView::OnULXmodem()  {
  489.  
  490.         xferObj->SendXY (commObj, ULPath.GetBuffer(ULPath.GetLength()), 'X');
  491.         ULPath.ReleaseBuffer();
  492. }
  493.   // XModem - 128 byte - CRC
  494. void CTtView::OnULXmodem128bytecrc()   {
  495.  
  496.         xferObj->SendXY (commObj, ULPath.GetBuffer(ULPath.GetLength()), 'C');
  497.         ULPath.ReleaseBuffer();
  498. }
  499.   // 1K XModem - CRC
  500. void CTtView::OnULXmodem1k()   {
  501.                                 
  502.         xferObj->SendXY (commObj, ULPath.GetBuffer(ULPath.GetLength()), 'K');
  503.         ULPath.ReleaseBuffer();
  504. }                               
  505.   // YModem/Batch
  506. void CTtView::OnULYmodem()   {
  507.  
  508.         xferObj->SendXY (commObj, ULPath.GetBuffer(ULPath.GetLength()), 'Y');
  509.         ULPath.ReleaseBuffer();
  510. }
  511.   // YModem-g/Batch 
  512. void CTtView::OnULYmodemg()   {
  513.                               
  514.         xferObj->SendXY (commObj, ULPath.GetBuffer(ULPath.GetLength()), 'G');
  515.         ULPath.ReleaseBuffer();
  516. }
  517.  
  518. ////////////////////////////////////////////////
  519. //  Check Carrier state flag
  520.  
  521. void CTtView::OnUtilsCheckCarrier()   {
  522.  
  523.         if( commObj->CarrierDetect() ) AfxMessageBox("We have Carrier !!");
  524.         else AfxMessageBox("Wah ! No Carrier !");
  525. }
  526.  
  527.  
  528.  
  529. /////////////////////////////////////////////////
  530. // Setup Default Upload Directory
  531. void CTtView::OnUtilsSetupUldir()  {
  532.  
  533.                 CFileDialog LoadDlg(TRUE,NULL,"SELECT",OFN_HIDEREADONLY,
  534.                                NULL, NULL);
  535.             
  536.             LoadDlg.m_ofn.lpstrTitle = "Select Upload Directory";
  537.                 
  538.                 CString TempCS = ULPath;  // set temp CString
  539.                 int index;
  540.                 if( (index = TempCS.ReverseFind('\\') ) != -1) 
  541.                                 TempCS = TempCS.Left(index);
  542.  
  543.                 LoadDlg.m_ofn.lpstrInitialDir = TempCS;
  544.                 if( LoadDlg.DoModal() == IDOK  )        {
  545.                         ULPath = LoadDlg.GetPathName();
  546.                         if( (index = ULPath.ReverseFind('\\') ) != -1) 
  547.                                 ULPath = ULPath.Left(index +1);
  548.                 AfxGetApp()->WriteProfileString("Main", "ULDir", ULPath);
  549.                 }           
  550. }
  551.  
  552. //////////////////////////////////////////////////
  553. //  Setup Default Download Directory 
  554.  
  555. void CTtView::OnUtilsSetupDldir()   {
  556.  
  557.                 CFileDialog LoadDlg(TRUE,NULL,"SELECT",OFN_HIDEREADONLY,
  558.                                NULL, NULL);
  559.             
  560.             LoadDlg.m_ofn.lpstrTitle = "Select Download Directory";
  561.                 
  562.                 CString TempCS = DLPath;  // set temp CString
  563.                 int index;
  564.                 if( (index = TempCS.ReverseFind('\\') ) != -1) 
  565.                                 TempCS = TempCS.Left(index);
  566.  
  567.                 LoadDlg.m_ofn.lpstrInitialDir = TempCS;
  568.                 if( LoadDlg.DoModal() == IDOK  )        {
  569.                         DLPath = LoadDlg.GetPathName();
  570.                         if( (index = DLPath.ReverseFind('\\') ) != -1) 
  571.                                 DLPath = DLPath.Left(index +1);
  572.                 AfxGetApp()->WriteProfileString("Main", "DLDir", DLPath);
  573.                 }           
  574. }
  575.  
  576. //////////////////////////////////////////
  577. //  Sets abort flag in commObj
  578. void CTtView::OnAbortdl()  {
  579.  
  580.         commObj->bAbortDownload = TRUE;
  581. }
  582.  
  583. ///////////////////////////////////////
  584. //  Resets over-run rcv buffer
  585. void CTtView::OnUtilsResetport()  {
  586.  
  587.         if(commObj->CommGetError() && 1) 
  588.             commObj->FlushReceiveQueue();
  589. }
  590.  
  591. //////////////////////////////////////////////////
  592. //   UI Updating for menu items - gray/disable during file xfers
  593.  
  594. void CTtView::OnUpdateAbortdl(CCmdUI* pCmdUI)   {
  595.  
  596.         if(!commObj->bDownloadActive) pCmdUI->Enable(FALSE);    
  597.     else pCmdUI->Enable(TRUE);
  598. }
  599.  
  600. void CTtView::OnUpdateDLXmodem(CCmdUI* pCmdUI)   {
  601.  
  602.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  603.     else pCmdUI->Enable(TRUE);
  604. }
  605.  
  606. void CTtView::OnUpdateDLYmodem(CCmdUI* pCmdUI)   {
  607.  
  608.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  609.     else pCmdUI->Enable(TRUE);
  610. }
  611.  
  612. void CTtView::OnUpdateDLYmodemg(CCmdUI* pCmdUI)   {
  613.  
  614.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  615.     else pCmdUI->Enable(TRUE);
  616. }
  617.  
  618. void CTtView::OnUpdateULXmodem(CCmdUI* pCmdUI)    {
  619.  
  620.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  621.     else pCmdUI->Enable(TRUE);
  622. }
  623.  
  624. void CTtView::OnUpdateULYmodem(CCmdUI* pCmdUI)    {
  625.  
  626.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  627.     else pCmdUI->Enable(TRUE);
  628. }
  629.  
  630. void CTtView::OnUpdateULYmodemg(CCmdUI* pCmdUI)   {
  631.  
  632.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  633.     else pCmdUI->Enable(TRUE);
  634. }
  635.  
  636. void CTtView::OnUpdateULXmodem128bytecrc(CCmdUI* pCmdUI)   {
  637.  
  638.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  639.     else pCmdUI->Enable(TRUE);
  640. }
  641.  
  642. void CTtView::OnUpdateULXmodem1k(CCmdUI* pCmdUI)   {
  643.  
  644.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  645.     else pCmdUI->Enable(TRUE);
  646. }
  647.  
  648. void CTtView::OnUpdateUtilsHangup(CCmdUI* pCmdUI)   {
  649.  
  650.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  651.     else pCmdUI->Enable(TRUE);
  652. }
  653.  
  654. void CTtView::OnUpdateUtilsSetupDldir(CCmdUI* pCmdUI)   {
  655.  
  656.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  657.     else pCmdUI->Enable(TRUE);
  658. }
  659.  
  660. void CTtView::OnUpdateUtilsSetupUldir(CCmdUI* pCmdUI)   {
  661.  
  662.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  663.     else pCmdUI->Enable(TRUE);
  664. }
  665.  
  666. void CTtView::OnUpdateUtilsResetport(CCmdUI* pCmdUI)  {
  667.  
  668.         if(commObj->bDownloadActive) pCmdUI->Enable(FALSE);     
  669.     else pCmdUI->Enable(TRUE);
  670. }
  671.  
  672.